package com.example.algorithm.linear.link;

import com.example.algorithm.linear.sequence.SequenceList;
import org.junit.Test;

import java.util.ArrayList;

/**
 * @program: algorithm
 * @description: 测试
 * @packagename: com.example.algorithm.linear.sequence
 * @author: Jay
 * @date: 2022/03/28 16:01:03
 **/
public class LinkListTest2 {

    @Test
    public void testInsert(){

        LinkList<String> list = new LinkList<>();
        //测试插入
        list.insert("尼克杨");
        list.insert("科比");
        list.insert("姚明");
        list.insert(1,"詹姆斯");

        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("------------------------------");
        list.reverse();
        for (String s : list) {
            System.out.println(s);
        }
    }

    @Test
    public void testSequence(){
        SequenceList<String> list = new SequenceList<>(3);
        list.insert("张三");
        list.insert("李四");
        list.insert("王五");
        list.insert(1,"赵六");
        ArrayList a;
    }

    @Test
    public void testTwoLinkList(){
        TwoWayLinkList<String> list = new TwoWayLinkList<>();
        //测试插入
        list.insert("尼克杨");
        list.insert("科比");
        list.insert("姚明");
        list.insert(1,"詹姆斯");

        for (String s : list) {
            System.out.println(s);
        }

        System.out.println("-------------------------------------");

        //测试获取
        System.out.println("获取索引1处的值"+list.get(1));

        System.out.println("清空后的顺序表的个数是"+list.length());
        System.out.println("++++++++++++++++++++++++++++++++");
        System.out.println("第一个元素："+list.getFirst());
        System.out.println("最后一个元素："+list.getLast());
        System.out.println("++++++++++++++++++++++++++++++++");
        //测试删除
        System.out.println("删除的元素是"+list.remove(0));
        //测试清空
        list.clear();
    }
}
